﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFScaffolderTest.ViewModels
{
    public class MainViewModel : INotifyPropertyChanged 
    {
        private object _Entity;
        public object Entity
        {
            get { return _Entity; }
            set 
            {
                if (value == _Entity)
                    return;

                _Entity = value;
                this.RaisePropertyChanged("Entity");
            }
        }


        private List<object> _Entities;

        public List<object> Entities
        {
            get { return _Entities; }
            set
            {
                if (value == _Entities)
                    return;

                _Entities = value;
                this.RaisePropertyChanged("Entiies");
            }
        }


        public MainViewModel()
        {
            Entities = new List<object>();
            Entities.Add(new Person
            {
                Name = "John Doe",
                Age = 30,
                BirthDate = new DateTime(1981, 12, 2),
                Cities = new List<string> { "LA", "OKC", "NY" }
            });
            Entities.Add(new Product
            {
                ProductName = "Flux Capacitor",
                ID = 1,
                Quantity = 1,
                Attributes = new List<string>{ "Power: 1.21 GigoWatts", "Source: Plutonium"}
            });
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
